<%--
  Created by IntelliJ IDEA.
  User: 1
  Date: 2020/10/17
  Time: 9:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c"
            uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt"
           uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <h3>fmt 格式化标签</h3>
    <div>
        <h4>fmt:formatNumber</h4>
        <span>
            <c:set var="balance" value="123456.2309"></c:set>
            <!--maxFractionDigits 小数点后最大的位数-->
            <p>格式化数字 (1): <fmt:formatNumber value="${balance}"
                                            type="currency"/></p>
<p>格式化数字 (2): <fmt:formatNumber type="number"
                                maxIntegerDigits="3" value="${balance}" /></p>
<p>格式化数字 (3): <fmt:formatNumber type="number"
                                maxFractionDigits="3" value="${balance}" /></p>
<p>格式化数字 (4): <fmt:formatNumber type="number"
                                groupingUsed="false" value="${balance}" /></p>
<p>格式化数字 (5): <fmt:formatNumber type="percent"
                                maxIntegerDigits="3" value="${balance}" /></p>
<p>格式化数字 (6): <fmt:formatNumber type="percent"
                                minFractionDigits="10" value="${balance}" /></p>
<p>格式化数字 (7): <fmt:formatNumber type="percent"
                                maxIntegerDigits="3" value="${balance}" /></p>
<p>格式化数字 (8): <fmt:formatNumber type="number"
                                pattern="###.###E0" value="${balance}" /></p>
<p>美元 :
<fmt:setLocale value="en_US"/>
<fmt:formatNumber value="${balance}" type="currency"/></p>
        </span>
    </div>

<div>
    <h3>formatDate
        <a target="_blank" href="https://www.runoob.com/jsp/jstl-format-formatdate-tag.html"></a>教程</h3>
    <span>
<c:set var="now" value="<%=new java.util.Date()%>" />
        <!--设置中国时区-->
<fmt:setLocale value="zh_CN"/>
<p>日期格式化 (1): <fmt:formatDate type="time"
                              value="${now}" /></p>
<p>日期格式化 (2): <fmt:formatDate type="date"
                              value="${now}" /></p>
<p>日期格式化 (3): <fmt:formatDate type="both"
                              value="${now}" /></p>
<p>日期格式化 (4): <fmt:formatDate type="both"
                              dateStyle="short" timeStyle="short"
                              value="${now}" /></p>
<p>日期格式化 (5): <fmt:formatDate type="both"
                              dateStyle="medium" timeStyle="medium"
                              value="${now}" /></p>
<p>日期格式化 (6): <fmt:formatDate type="both"
                              dateStyle="long" timeStyle="long"
                              value="${now}" /></p>
<p>日期格式化 (7): <fmt:formatDate pattern="yyyy-MM-dd"
                              value="${now}" /></p>
    </span>
</div>

<div>
    <h3>timezone</h3>
    <c:set var="now" value="<%=new java.util.Date()%>" />
    <table border="1" width="100%">
        <tr>
            <td width="100%" colspan="2" bgcolor="#0f0f0f">
                <p align="center">
                    <b>
                        <font color="#f0f0f0" size="4">Formatting:
                            <fmt:formatDate value="${now}" type="both"
                                            timeStyle="long" dateStyle="long" />
                        </font>
                    </b>
                </p>
            </td>
        </tr>

        <c:forEach var="zone"
                   items="<%=java.util.TimeZone.getAvailableIDs()%>">
            <tr>
                <td width="51%">
                    <c:out value="${zone}" />
                </td>
                <td width="49%">
                    <fmt:timeZone value="${zone}">
                        <fmt:formatDate value="${now}" timeZone="${zn}"
                                        type="both" />
                    </fmt:timeZone>
                </td>
            </tr>
        </c:forEach>
    </table>
</div>
</body>
</html>
